<!-- 文章展示 -->
<template>
  <view class="goods-detail-intro">
    <mp-html class="richtext" :content="state.content" />
  </view>
</template>

<script setup>

import { onLoad } from '@dcloudio/uni-app';

import { reactive } from 'vue';

import { getArticleByTitle } from '@/api/article.js';

const state = reactive({
  title: '',
  content: '',
});

function getArticleByTitleReq() {
  getArticleByTitle(state.title).then((res) => {
    if (res) {
      if (res.data?.content) {
        state.content = `<div>${res.data.content} </div>`;
      } else {
        state.content = `<div style="color:rgb(160, 160, 179);font-size:28rpx;">暂无数据</div>`;
      }
    }
  });
}

onLoad((options) => {
  state.title = options.title;
  uni.setNavigationBarTitle({
    title: state.title,
  });
  getArticleByTitleReq();
});

</script>

<style lang="scss" scoped>
.goods-detail-intro {
  margin:24rpx;
  color: #545567;
  font-family: PingFang SC;
  font-size: 24rpx;
}
</style>
